<template>
	<view class="container">
		<view class="list">
			<view class="item bg-fff" v-for="(item,index) in list" :key="index" @click="jump('/pages/shop/shop_info?shop_supplier_id='+item.shop_supplier_id)">
				<view class="shop flex">
					<image class="shop-image" :src="item.logo"></image>
					<view class="shop-con">
						<view class="shop-name flex-space-between">
							<view>{{item.store_name}}</view>
							<text>店铺评分</text>
						</view>
						<view class="shop-brand flex-space-between">
							<view>主营品牌：{{item.categoryName}}</view>
							<text>{{item.score}}</text>
						</view>
						<view class="shop-sales">
							<view>销量：{{item.product_sales}}件</view>
						</view>
					</view>
				</view>
				
				<view class="product flex-space-between">
					<view class="flex-align-center" style="flex: 1;">
						<view style="margin-right: 20rpx;" v-for="(it,idx) in item.productList" :key="idx" @click.stop="jump('/pages/categoty/product/product?id='+it.product_id)">
							<image class="product-image" :src="it.logo"></image>
							<view class="product-name u-line-1">{{it.product_name}}</view>
							<view class="product-price">{{it.product_price}}</view>
						</view>
					</view>
					<image :src="$setting.imageUrl()+'CircleRight.png'" class="product-icon"></image>
				</view>
			</view>
		</view>
		
		<view v-if="list.length > 0">
			<b-u-loadmore :status="loadmoreStatus"></b-u-loadmore>
		</view>
		<view v-else style="padding-top: 100rpx;">
			<u-empty text="暂无数据" mode="data"></u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageForm: {
					page: 1,
					list_rows: 20,
					type: 10,
				},
				list: [],
				loadmoreStatus: 'nomore',
			}
		},
		onLoad() {
			this.getHttp();
		},
		onReachBottom() {
			if(this.loadmoreStatus == 'nomore') {
				return;
			}
			this.pageForm.page++;
			this.getFavorite();
		},
		methods: {
			jump(url) {
				uni.navigateTo({
					url: url
				})
			},
			getFavorite() {
				this.loadmoreStatus = 'loading';
				uni.$u.api.getFavorite(this.pageForm).then(res => {
					this.list = this.list.concat(res.list.data);
					this.loadmoreStatus = 'loadmore';
					if(this.list.length  == res.list.total) {
						this.loadmoreStatus = 'nomore';
					}
				})
			},
			getHttp() {
				this.getFavorite();
			},
		},
	}
</script>

<style lang="scss" scoped>
	.container {
		.list {
			padding: 30rpx;
			
			.item {
				border-radius: 16rpx;
				margin-bottom: 24rpx;
				padding: 34rpx 30rpx;
				
				.shop {
					padding-bottom: 28rpx;
					border-bottom: 1px solid rgba(225, 225, 225, 0.7);
					
					.shop-image {
						width: 128rpx;
						height: 128rpx;
						border-radius: 16rpx;
					}
					
					.shop-con {
						flex: 1;
						margin-left: 16rpx;
						
						.shop-name {
							font-size: 28rpx;
							color: #111111;
							font-weight: bold;
							
							text {
								font-weight: normal;
							}
						}
						
						.shop-brand {
							margin-top: 22rpx;
							font-size: 24rpx;
							color: #666666;
							
							text {
								font-size: 28rpx;
								color: $uni-color-theme;
							}
						}
						
						.shop-sales {
							margin-top: 10rpx;
							font-size: 24rpx;
							color: #666666;
						}
					}
				}
				
				.product {
					margin-top: 24rpx;
					
					.product-image {
						width: 160rpx;
						height: 160rpx;
						border-radius: 16rpx;
					}
					
					.product-name {
						width: 160rpx;
						margin-top: 14rpx;
						font-size: 24rpx;
						color: #111111;
					}
					
					.product-price {
						font-size: 24rpx;
						font-weight: bold;
						color: $uni-color-theme;
					}
					
					.product-icon {
						width: 48rpx;
						height: 48rpx;
						margin-left: 30rpx;
					}
				}
			}
		}
	}
</style>
